package com.zhtools;

/**
 * add by zhanghao at 2017/11/8
 */
public class CodeEnumUtil {
    public static <E extends Enum<?> & EnumCode> E codeOf(Class<E> enumClass, String code) {
        E[] enumConstants = enumClass.getEnumConstants();
        for (E e : enumConstants) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        return null;
    }
}
